using System;
using System.Threading;
using Shraga.BLL;

namespace Shraga.Client
{
	/// <summary>
	/// Summary description for NotesThread.
	/// </summary>
	public class NotesThread
	{

		private int m_waitSecond = -1;
		private NotesList m_frmNotesListWindow;
		private delegate void FunctionDelegate();

		public NotesThread(int RefreshSecond, NotesList NotesListWindow)
		{
			m_waitSecond = RefreshSecond;
			m_frmNotesListWindow = NotesListWindow;
		}

		public void DoLoop()
		{
			while(true)
			{
				OnTimer();
				Thread.Sleep(new TimeSpan(0,0,m_waitSecond));				
			}
		}

		private void OnTimer()
		{
			try
			{
				m_frmNotesListWindow.Invoke(new FunctionDelegate(m_frmNotesListWindow.FillData));
			}
			catch (Exception ex)
			{
				int r;
				r = 1;
			}
		}
	}
}
